<%-- 
    Document   : index
    Created on : 8 avr. 2012, 17:03:33
    Author     : Cranberry
--%>
<%@page language="java" session="true" %>
<%@page language="java" session="true" %>
<%@page import="java.util.List"%>
<%@page import="bmg.Category"%>
<%@page import="bmg.Product"%>
<%@page import="model.ShoppingCart"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<jsp:include page="inc/header.jsp">
    <jsp:param name="title" value="Affichage d'une catégorie" />
</jsp:include>

<div class="ym-col1">
    
    <div class="ym-cbox">
        
        <div class="box info">
            <% Category current_category = (Category) request.getAttribute("current_category"); %>
            Vous parcourez actuellement la catégorie <strong><%= current_category.getName().getValue() %></strong><br /><br />
            <%= current_category.getDescription().getValue() %>
        </div>
        
        <% List<Product> products = (List<Product>) request.getAttribute("products"); %>
        
        <table>
            <thead>
                <tr>
                    <th>N°</th>
                    <th>Nom</th>
                    <th>Prix</th>
                    <th>Disponibilité</th>
                    <th></th>
                </tr>
            </thead>
            <% for(Product p : products){ %>
            <tr>
                <td><%= p.getID() %></td>
                <td><a href="<% request.getContextPath(); %>?action=show_product&product_id=<%= p.getID() %>"><%= p.getName().getValue() %></a></td>
                <td><%= p.getPrice() %>€</td>
                <% if(p.getStock() == 0){ %>
                <td><img src="/bmg/assets/img/stock-blanc.gif"></td>
                <% } else if(p.getStock() > 0 && p.getStock() <= 50){ %>
                <td><img src="/bmg/assets/img/stock-bleu.gif"></td>
                <% } else if(p.getStock() > 50){ %>
                <td><img src="/bmg/assets/img/stock-vert.gif"></td>
                <% } %>
                <td><a href="<% request.getContextPath(); %>?action=add_basket&product_id=<%= p.getID() %>"><img src="/bmg/assets/img/shop_cart.png"></a></td>
            </tr>
            <% } %>
        </table>
    </div>    
        
</div>
        
<jsp:include page="menu.jsp" />      
        
<jsp:include page="inc/footer.jsp" />